Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsrsasign

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsrsasign

opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp and CAdES and JSON Web Signature(JWS)/Token(JWT)/Key(JWK)

  • 8.0.24
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
549K
decreased by-29.99%
Maintainers
1
Weekly downloads
 
Created

What is jsrsasign?

The jsrsasign npm package is a comprehensive library for cryptographic operations, including RSA/DSA/ECDSA key generation, digital signatures, X.509 certificate handling, and more. It is widely used for implementing security features in JavaScript applications.

What are jsrsasign's main functionalities?

RSA Key Generation

This feature allows you to generate RSA key pairs. The code sample demonstrates generating a 2048-bit RSA key pair using the KEYUTIL.generateKeypair method.

const rsaKeypair = KEYUTIL.generateKeypair('RSA', 2048);
console.log(rsaKeypair);

Digital Signature

This feature allows you to create digital signatures. The code sample shows how to sign a message using an RSA private key and the SHA256withRSA algorithm.

const rsa = new RSAKey();
rsa.readPrivateKeyFromPEMString('-----BEGIN PRIVATE KEY-----...');
const sig = new KJUR.crypto.Signature({alg: 'SHA256withRSA'});
sig.init(rsa);
sig.updateString('message');
const signature = sig.sign();
console.log(signature);

X.509 Certificate Handling

This feature allows you to handle X.509 certificates. The code sample demonstrates reading a PEM-encoded certificate and extracting the subject string.

const pemCert = '-----BEGIN CERTIFICATE-----...';
const x509 = new X509();
x509.readCertPEM(pemCert);
console.log(x509.getSubjectString());

JWT (JSON Web Token) Handling

This feature allows you to create and verify JSON Web Tokens (JWT). The code sample shows how to sign a JWT using the HS256 algorithm and a secret key.

const header = {alg: 'HS256', typ: 'JWT'};
const payload = {sub: '1234567890', name: 'John Doe', iat: 1516239022};
const sHeader = JSON.stringify(header);
const sPayload = JSON.stringify(payload);
const sJWT = KJUR.jws.JWS.sign('HS256', sHeader, sPayload, 'secret');
console.log(sJWT);

Other packages similar to jsrsasign

Keywords

FAQs

Package last updated on 18 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc